/*
 * launcher.cpp
 */
#include "../middleware/CommunicationVendedor.h"
#include "../middleware/CommunicationAdpt.h"
#include "../middleware/CommunicationDespacho.h"
#include "../middleware/CommunicationRobot16.h"
#include "../middleware/CommunicationRobot5.h"
#include "../application/AdminKeys.h"
#include "clienteCommon.h"
#include "../middleware/CommunicationCanastos.h"
#include "../middleware/CommunicationRobot11.h"
#include "../middleware/CommunicationRobot12.h"
#include "../middleware/CommunicationAGV.h"
#include "../middleware/CommunicationPrimerCinta.h"
#include "DefinicionesComunes.h"
#include "ProcessAux.h"
#include "Cinta13A.h"
#include "Cinta13B.h"
#include "Cinta15.h"
#include "Robot11AProductor.h"
#include "Robot11BProductor.h"
#include "Robot14Consumidor.h"
#include "Robot14Productor.h"
#include "Robot16Consumidor.h"
#include "../middleware/CommunicationADP.h"

int main(int argc, char **argv)
{
	ipc::Sequence::create(CLIENTEID_SEQUENCE_PATH,CLIENTEID_SEQUENCE_KEY);
	middleware::CommunicationVendedor::create();
	middleware::CommunicationAdpt::create();
	middleware::CommunicationDespacho::create();
	middleware::CommunicationRobot16::create();

	/* Communications de produccion */
	AdminKeys adminZonaIzq(ZONA_IZQ);
	AdminKeys adminZonaMedio(ZONA_MED);
	AdminKeys adminZonaDer(ZONA_DER);

	middleware::CommunicationADP::create();
	middleware::CommunicationRobot5::create();

	middleware::CommunicationCanastos::create(adminZonaIzq.getCanastosKey());
	middleware::CommunicationCanastos::create(adminZonaDer.getCanastosKey());
	middleware::CommunicationCanastos::create(adminZonaMedio.getCanastosKey());

	middleware::CommunicationRobot11::create(adminZonaIzq.getRobot11Key());
	middleware::CommunicationRobot11::create(adminZonaDer.getRobot11Key());

	middleware::CommunicationRobot12::create(adminZonaMedio.getLeftRobot12Key());
	middleware::CommunicationRobot12::create(adminZonaMedio.getRightRobot12Key());

	middleware::CommunicationAGV::create(adminZonaIzq.getAgvKey());
	middleware::CommunicationAGV::create(adminZonaDer.getAgvKey());
	middleware::CommunicationAGV::create(adminZonaMedio.getAgvKey());

	middleware::CommunicationPrimerCinta::create(adminZonaIzq.getCintaKey());
	middleware::CommunicationPrimerCinta::create(adminZonaDer.getCintaKey());

    Cinta13A::create();
    Cinta13B::create();
    Cinta15::create();
    Robot11AProductor::create();
    Robot11BProductor::create();
    Robot14Consumidor::create();
    Robot14Productor::create();
    Robot16Consumidor::create();

    std::string robot11APath = "./controlR11A";
    std::string robot11BPath = "./controlR11B";
    std::string robot14Path  = "./controlR14";
    std::string robot16Path  = "./controlR16";

    if ( argc > 1 )
    {
        ProcessAux::launchProcess2( robot11APath );
        ProcessAux::launchProcess2( robot11BPath );
        ProcessAux::launchProcess2( robot14Path );
        ProcessAux::launchProcess2( robot16Path );
    }

	return 0;
}
